package com.example.jinyongjie.test_opengles.objects;

import com.example.jinyongjie.test_opengles.programs.ColorShaderProgram;
import com.example.jinyongjie.test_opengles.programs.TextureShaderProgram;
import com.example.jinyongjie.test_opengles.util.Constants;
import com.example.jinyongjie.test_opengles.util.VertexArray;

import static android.opengl.GLES20.GL_TRIANGLES;
import static android.opengl.GLES20.*;

/**
 * Created by jinyongjie on 17/3/23.
 */
public class Mallet {
    private static  final  int POSITION_COMPONENT_COUNT = 2;


    private static final float[] VERTEX_DATA = {
            -0.5f,0f,
            0.5f,0f,

            0f,-0.4f,
            0f,0.4f,
    };
    private VertexArray m_vertexArray;
    public Mallet()
    {
        m_vertexArray = new VertexArray(VERTEX_DATA);
    }
    public void bindData(ColorShaderProgram program)
    {
        m_vertexArray.setVertexAttribPointer(0,
                program.getPositionAttributeLocation(),
                POSITION_COMPONENT_COUNT,
                0);

    }

    public void draw(ColorShaderProgram program)
    {
        glUniform4f(program.getColorUniformLocation(), 1.0f, 0.0f, 0.0f, 1.0f);
        glDrawArrays(GL_LINES, 0, 2);

        glUniform4f(program.getColorUniformLocation(), 0.0f, 0.0f, 1.0f, 1.0f);
        glDrawArrays(GL_POINTS, 2, 1);

        glUniform4f(program.getColorUniformLocation(), 0.0f, 1.0f, 0.0f, 1.0f);
        glDrawArrays(GL_POINTS, 3, 1);
    }
}
